package com.mengxuegu.oauth2.controller;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.core.Authentication;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.nio.charset.StandardCharsets;


@RestController
@RequestMapping(value = "/user")
public class UserController {
    @RequestMapping(value = "/getCurrentUser")
    @PreAuthorize("hasAnyAuthority('ROLE_ADMIN')")
    public Object getCurrentUser(Authentication authentication) {
        return authentication.getPrincipal();
    }
}
